package com.xjoyt.pay.master.controllers;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xjoyt.pay.controllers.AbstractController;
import com.xjoyt.pay.dto.ExecuteResult;
import com.xjoyt.pay.dto.PageParam;
import com.xjoyt.pay.dto.PageResult;
import com.xjoyt.pay.master.interfaces.ChannelContract;
import com.xjoyt.pay.master.params.ChannelPageParam;
import com.xjoyt.pay.master.po.Channel;
import com.xjoyt.pay.master.services.ChannelService;

@RestController
@RequestMapping("channel")
public class ChannelController extends AbstractController implements ChannelContract {

	@Autowired
	private ChannelService service;

	// @Autowired
	// private CommonContract commonContract;

	@Override
	public Channel get(@PathVariable("id") String id) {
		return service.get(id);
	}

	@Override
	public ExecuteResult<Channel> save(@RequestBody Channel entity) {
		return service.save(entity);
	}

	@Override
	public ExecuteResult<?> remove(@PathVariable("id") String id) {
		return service.delete(id);
	}

	@Override
	public ExecuteResult<?> invokeRegisterChannel(@RequestBody List<String> ids) {
		return service.invokeRegisterChannel(ids);
	}

	@Override
	public ExecuteResult<?> invokeRegisterChannelDiversity(@RequestBody List<String> ids) {
		return service.invokeRegisterChannelDiversity(ids);
	}

	@Override
	public PageResult<Channel> loadPage(@RequestBody PageParam<ChannelPageParam> param) {
		return service.loadPage(param);
	}

	@Override
	public List<Channel> findAllHealthEnabled(@PathVariable("enabled") Boolean enabled) {
		return service.findAllHealthEnabled(enabled);
	}
}
